package com.hertz.appr.util;

import java.io.File;
import java.util.Map;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;

public class PropertiesHelper {
	private static PropertiesConfiguration config;
	
	public static PropertiesConfiguration getConfiguration(){
		if(config != null)
			return config;
		else{
			try {
				String filePath = Configuration.getProperty("variables.properties");
				File file = new File(filePath);
				config = new PropertiesConfiguration(file);
				config.setAutoSave(true);
				FileChangedReloadingStrategy frs = new FileChangedReloadingStrategy();
				
//				frs.setRefreshDelay(1000)
				config.setReloadingStrategy(frs);
			} catch (ConfigurationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}  
			return config;
		}
	}

}
